<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!-- 规划教室 -->

<div id="dialog-message">
		<form id="register_from">
				<input type="hidden" id="sys_Class_table_id" name="sys_Class_table_id" value="${param.table_id}">
					 <table>
					 	<tr>
					 		<td width="50%">
					 		<fieldset>
								<label>所属班级：</label>
								<input type="hidden" id=''>
								<input type="text" id="cname" value="${param.pName}"  name="cname" disabled="disabled"   title="${param.pName}" />
								<span class="help-block"></span> 
							</fieldset>
					 		</td> 
					 	</tr>
					 	<tr>
					 		<td width="50%">
					 		<fieldset>
								<label>行：</label>
								<input type="text" id="x1" value="${param.x}" require='true' name="x1"    meth="notNull,isNumber" maxlength="2" value="0" title="行数，必须为数字类型" />
								<span class="help-block"></span> 
							</fieldset>
					 		</td> 
					 	</tr>
					 	<tr>
					 		<td width="50%">
					 		<fieldset>
								<label>列：</label>
								<input type="text" id="y1" value="${param.y}" require='true' name="y1" meth="notNull,isNumber" style="width:107px" maxlength="2" value="0" title="列数，必须为数字类型" />
								<button type="button" id="guihua">规划</button>
							</fieldset>
					 		</td> 
					 	</tr>
					 	<tr>
					 		<td width="50%">
					 		<fieldset>
								<label>地址：</label>
								<input type="text" id="addess" value="${param.addess}" name="addess"   title="请输入教室所有在地址" />
								 
							</fieldset>
					 		</td> 
					 	</tr>
					 	<tr>
					 		<td width="50%">
					 		<fieldset>
								<label>gps：</label>
								<input type="text" id="gps" value="${param.gps}" name="gps" meth="" maxlength="2"  title="用户名称不能少于4位，由英文和数字组成" />
								<span class="help-block"></span> 
							</fieldset>
					 		</td> 
					 	</tr>
					 		<tr>
					 		<td width="50%">
					 		<fieldset>
								<label>状态：</label>
								 <select id="state" style="width:155px;">
								 	<option value="1">启用</option>
								 	<option value="0">禁用</option>
								 </select>
								 
								<span class="help-block"></span> 
							</fieldset>
					 		</td> 
					 	</tr>
					 	 
					 </table>  
				</form>	 
		 <div id="myclass_ggjs" style="margin:0 auto;border:1px solid gray;text-align:center;">
			
		
		 </div>
</div>				
<script>
(function(){
	var chair ='<img name="chair"  state="1" src="${pageContext.request.contextPath}/image/chair.png" style="margin-left:10px;margin-top:10px;">';
	var chair1 ='<img name="chair" state="0"  src="${pageContext.request.contextPath}/image/chair1.png"  style="margin-left:10px;margin-top:10px;">';
	var arr = new Array();
	var xy =function(){
		var a =$("#register_from").hzValidate("init");  
		if(a==false){
			return;
		}
		var x =parseInt($("#x1").val());
		var y =parseInt($("#y1").val());
		
		$("#myclass_ggjs").width(38*x);
		$("#myclass_ggjs").height(38*y+5); 
		for(var i=0;i<x;i++){
			for(var j=0;j<y;j++){ 
				var b =$(chair);
				$("#myclass_ggjs").append(b);
				b.attr("x1",i+1);
				b.attr("y1",j+1);
				 
			}
		}
		$("img[name=chair]").click(function(){
			if($(this).attr("state")=="0"){
				$(this).attr("state","1");
				$(this).attr("src","${pageContext.request.contextPath}/image/chair1.png");			
			}else{
				$(this).attr("state","0");
				$(this).attr("src","${pageContext.request.contextPath}/image/chair.png");	
			} 
		});
	    
	
	};
	//增加教室位置
	function addClassRoom(control){
		var a =$("#register_from").hzValidate("init");  
		if(a==false){
			return;
		}
		var object1 = OAajaxSubmit("register_from");  
	 
		var img = $("img[name=chair]");
		var arr = new Array();
		for(var i=0;i<img.length;i++){
			var object = new Object();
			object.state=$(img[i]).attr("state");
			object.x1 = $(img[i]).attr("x1");
			object.y1 = $(img[i]).attr("y1");
			arr.push(object);
		}
		if(arr.length<=0){
			alert("你没有成功规划教室");
			return;
		}
		object1.arr=obj2str(arr);
		var url ="${pageContext.request.contextPath}/edu/sysClassAction.do?method=addClass_Room&r="+Math.random();
		$.ajax({ 
			   type: "POST",
			   url: url,
			   data:object1,
			   dataType:'json',
			   success: function(msg){  
				   alert(msg.message);
			        if(msg.code=="1"){
			        	$(control).dialog('destroy'); 
						$("#user_include").html("");
			        }
			   }
			});
		
		
	};
	$(function(){
	  
		 $("#guihua").click(xy);
	});
	window.class_roomAdd={};
	
	window.class_roomAdd.addClassRoom =addClassRoom;
	 
})();
</script>